﻿Imports Mystery

Public Class ContentViewAttribute
    Inherits MysteryDefaultClassAttribute

    Public Property implementing_type As Type

    Public Property new_window_height As Integer = 400
    Public Property new_window_width As Integer = 600

    Private _button_activator As IActivator

    Public Overrides Sub setUp()
        If implementing_type IsNot Nothing Then
            If implementing_type.GetInterface(GetType(IContentShower).FullName) Is Nothing Then
                Throw New Exception(_implementing_type.FullName & " must implement " & GetType(IContentShower).FullName)
            End If
        Else
            implementing_type = GetType(ContentView)
        End If

        _button_activator = getGlobalObject(Of FastActivator).getActivator(implementing_type)
    End Sub

    Public Function createControl(content As IContent) As UserControl
        Dim content_view As IContentShower = _button_activator.createInstance()
        content_view.show(content)
        Return content_view
    End Function

End Class
